﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using Model;

namespace BusinnessLogic
{
    public class ImpedimentsManage
    {
        public List<Impediments> FillImpedimentsViewtje()
        {
            DataLayer.DLimpediments dlimpobject = new DataLayer.DLimpediments();
            DataSet mydataset = dlimpobject.impedimentslist();
            List<Impediments> impedimentslist = new List<Impediments>();
            
            for (int i = 0; i < mydataset.Tables[0].Rows.Count ; i++)
            {
                Impediments imp = new Impediments();
                imp.impedimentID = int.Parse(mydataset.Tables[0].Rows[i]["ImpedimentID"].ToString());
                imp.titel = mydataset.Tables[0].Rows[i]["Titel"].ToString();
                imp.Username = mydataset.Tables[0].Rows[i]["Login"].ToString();
                imp.Task = mydataset.Tables[0].Rows[i]["TTitel"].ToString();


                impedimentslist.Add(imp);
                
            }
            return impedimentslist;
        }
        public List<Impediments> DetailList(int id)
        {
            DataLayer.DLimpediments impedimentsdetails = new DataLayer.DLimpediments();
            DataSet mydataset = impedimentsdetails.ImpedimentsDetailList(id);
            List<Impediments> detaillist = new List<Impediments>();

            for (int i = 0; i < mydataset.Tables[0].Rows.Count; i++)
            {
                string username = mydataset.Tables[0].Rows[i]["Login"].ToString();
                string product = mydataset.Tables[0].Rows[i]["Name"].ToString();
                string sprint = mydataset.Tables[0].Rows[i]["Expr1"].ToString();
                string userstory = mydataset.Tables[0].Rows[i]["Expr4"].ToString();
                string task = mydataset.Tables[0].Rows[i]["Expr3"].ToString();
                string titel = mydataset.Tables[0].Rows[i]["titel"].ToString();
                string desc = mydataset.Tables[0].Rows[i]["Description"].ToString();
                int impID = int.Parse(mydataset.Tables[0].Rows[i]["ImpedimentID"].ToString());
                int taskID = int.Parse(mydataset.Tables[0].Rows[i]["TaskId"].ToString());
                Impediments imp = new Impediments(impID,titel,desc,taskID,username,product,sprint,userstory,task);

                detaillist.Add(imp);

            }
            return detaillist;
            
        }

        public void InsertImp(string titel, string description, int taskid)
        {
            DataLayer.DLimpediments tempSave = new DataLayer.DLimpediments();
            tempSave.InsertImpedimentDB(titel, description, taskid);
        }


        }
    }

